from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites: www.linuxhowtos.org
toolsntoys.linuxhowtos.org



Last additions:
How to make X listen on port 6000

How to make X listen on port 6000

words:

34

views:

82656

userrating:

average rating: 1.2 (52 votes) (1=very good 6=terrible)


May, 25th 2007:
April, 26th 2007:
Apr, 10th. 2007:
Druckversion . pdf icon
You are here: Misc

Gentoo udev Guide


1. What is udev?


The /dev Directory


When Linux-users talk about the hardware on their system in the vicinity of people who believe Linux is some sort of virus or brand of coffee, the use of "slash dev slash foo" will return a strange look for sure. But for the fortunate user (and that includes you) using /dev/hda1 is just a fast way of explaining that we are talking about the primary master IDE, first partition. Or aren't we?
We all know what a device file is. Some even know why device files have special numbers when we take a closer look at them when we issue ls -l in /dev. But what we always take for granted is that the primary master IDE disk is referred to as /dev/hda. You might not see it this way, but this is a flaw by design.
Think about hotpluggable devices like USB, IEEE1394, hot-swappable PCI, ... What is the first device? And for how long? What will the other devices be named when the first one disappears? How will that affect ongoing transactions? Wouldn't it be fun that a printing job is suddenly moved from your supernew laserprinter to your almost-dead matrix printer because your mom decided to pull the plug of the laserprinter which happened to be the first printer?


Enter udev. The goals of the udev project are both interesting and needed:
- Runs in userspace
- Dynamically creates/removes device files
- Provides consistent naming
- Provides a user-space API
To provide these features, udev is developed in three separate projects: namedev, libsysfs and, of course, udev.

namedev


Namedev allows you to define the device naming separately from the udev program. This allows for flexible naming policies and naming schemes developed by separate entities. This device naming subsystem provides a standard interface that udev can use.
Currently only a single naming scheme is provided by namedev; the one provided by LANANA, used by the majority of Linux systems currently and therefore very suitable for the majority of Linux users.
Namedev uses a 5-step procedure to find out the name of a given device. If the device name is found in one of the given steps, that name is used. The steps are:
- label or serial number
- bus device number
- bus topology
- statically given name
- kernel provided name

The label or serial number step checks if the device has a unique identifier. For instance USB devices have a unique USB serial number; SCSI devices have a unique UUID. If namedev finds a match between this unique number and a given configuration file, the name provided in the configuration file is used.
The bus device number step checks the device bus number. For non-hot-swappable environments this procedure is sufficient to identify a hardware device. For instance PCI bus numbers rarely change in the lifetime of a system. Again, if namedev finds a match between this position and a given configuration file, the name provided in that configuration file is used.
Likewise the bus topology is a rather static way of defining devices as long as the user doesn't switch devices. When the position of the device matches a given setting provided by the user, the accompanying name is used.
The fourth step, statically given name, is a simple string replacement. When the kernel name (the default name) matches a given replacement string, the substitute name will be used.
The final step (kernel provided name) is a catch-all: this one takes the default name provided by the kernel. In the majority of cases this is sufficient as it matches the device naming used on current Linux systems.

libsysfs


udev interacts with the kernel through the sysfs pseudo filesystem. The libsysfs project provides a common API to access the information given by the sysfs filesystem in a generic way. This allows for querying all kinds of hardware without having to make assumptions on the kind of hardware.

udev


Every time the kernel notices an update in the device structure, it calls the /sbin/hotplug program. Hotplug runs the applications linked in the /etc/hotplug.d/default directory where you will also find a symlink to the udev application. Hotplug directs the information given by the kernel to the udev application which performs the necessary actions on the /dev structure (creating or deleting device files).

2. Using udev on Gentoo


Requirements


udev is meant to be used in combination with a 2.6 kernel (like development-sources or gentoo-dev-sources). If you're using such a kernel then you just have to make sure that you have a recent sys-apps/baselayout version. That's all you need.
Code Listing 2.1: Installing udev
# emerge udev

udev will install hotplug-base as one of it's dependencies. You do not need to install hotplug unless you want your modules automatically loaded when you plug devices in. hotplug also handles the automated bringup of network devices and firmware downloading.
Code Listing 2.2: Installing optional hotplug scripts
# emerge hotplug

If you want modules loaded for devices that have been plugged in before you boot, use the coldplug package:
Code Listing 2.3: Installing the coldplug package
# emerge coldplug

Kernelwise, if you're using the default set by genkernel then you're all set. Otherwise be sure to activate the following options:
Code Listing 2.4: Required kernel options
General setup --->   
[*] Support for hot-pluggable devices

File systems --->
Pseudo filesystems --->
[*] /proc file system support
[*] Virtual memory file system support (former shm fs)

You can leave the /dev file system support (OBSOLETE) active if you wish but you have to make sure that "Automatically mount at boot" is disabled:
Code Listing 2.5: Don't automatically mount devfsd
File systems --->   
Pseudo Filesystems --->
[*] /dev file system support (OBSOLETE)
[ ] Automatically mount at boot

Configuration


If you want to use the udev-tweaks Gentoo added to make your life comfortable, then read no more. Gentoo will use udev but keep a static /dev so that you will never have any missing device nodes. The Gentoo init scripts won't run the devfsd daemon and will deactivate devfs when you boot up.

But if you are a die-hard and want to run a udev-only, no-tweaked system as is intended by the udev development (including the difficulties of missing device nodes because udev doesn't support them yet), by all means, read on :)

We'll deactivate the rules that save the device file nodes: edit the RC_DEVICE_TARBALL variable in /etc/conf.d/rc and set it to no:
Code Listing 2.6: /etc/conf.d/rc
RC_DEVICE_TARBALL="no"

If you have included devfs support in your kernel, you can deactivate it in the bootloader configuration: add gentoo=nodevfs as a kernel parameter. If you want to use devfs and deactivate udev, add gentoo=noudev as kernel parameter.

3. Known Issues


Missing device node files at boot


If you can't boot successfully because you get an error about /dev/null not found, or because the initial console is missing, the problem is that you lack some device files that must be available before /dev is mounted and handled by udev. This is common on Gentoo machines installed from old media.

If you run sys-apps/baselayout-1.8.12 or later, this problem is alleviated since the boot process should still manage to complete. However, to get rid of those annoying warnings, you should create the missing device nodes as described below.

To see which devices nodes are present before the /dev filesystem is mounted, run the following commands:
Code Listing 3.1: Listing device nodes available at boot
# mkdir test   
# mount --bind / test
# cd test/dev
# ls

The devices needed for a successful boot are /dev/null and /dev/console. If they didn't show up in the previous test, you have to create them manually. Issue the following commands in the test/dev/ directory:
Code Listing 3.2: Creating necessary device node files
# mknod -m 660 console c 5 1   
# mknod -m 660 null c 1 3

When you're finished, don't forget to unmount the test/ directory:
Code Listing 3.3: Unmounting the test/ directory
# cd ../..   
# umount test
# rmdir test

udev and nvidia


If you use the proprietary driver from nVidia and the X server fails to start on a udev-only system, then make sure you have:

the nvidia module listed in /etc/modules.autoload.d/kernel-2.6
a version of nvidia-kernel equal to or greater than media-video/nvidia-kernel-1.0.5336-r2
a version of baselayout equal to or greater than sys-apps/baselayout-1.8.12

LVM2 Names Disappear


When you use udev and LVM2 together, you might notice that your created volume groups and logical volumes have disappeared. Well, they haven't, but they are unfortunately named /dev/dm-# with # being 0, 1, ...

To fix this, edit /etc/udev/rules.d/50-udev.rules and uncomment the following line:
Code Listing 3.4: Uncomment this line from /etc/udev/rules.d/50-udev.rules
KERNEL="dm-[0-9]*",     PROGRAM="/sbin/devmap_name %M %m", NAME="%k", SYMLINK="%c"

No Consistent Naming between DevFS and udev


Even though our intention is to have a consistent naming scheme between both dynamical device management solutions, sometimes naming differences do occur. One reported clash is with a HP Smart Array 5i RAID controller (more precisely the cciss kernel module). With udev, the devices are named /dev/cciss/cXdYpZ with X, Y and Z regular numbers. With devfs, the devices are /dev/hostX/targetY/partZ or symlinked from /dev/cciss/cXdY.

If this is the case, don't forget to update your /etc/fstab and bootloader configuration files accordingly.

Other issues


If device nodes are not created when a module is loaded from /etc/modules.autoload.d/kernel-2.6 but they appear when you load the module manually with modprobe then you should try upgrading to sys-apps/baselayout-1.8.12 or later.

Support for the framebuffer devices (/dev/fb/*) comes with the kernel starting from version 2.6.6-rc2.

For kernels older than 2.6.4 you have to explicitly include support for the /dev/pts filesystem.
Code Listing 3.5: Enabling the /dev/pts filesystem
File systems --->   
Pseudo filesystems --->
[*] /dev/pts file system for Unix98 PTYs

4. Resources & Acknowledgements


The udev talk on the Linux Symposium (Ottawa, Ontario Canada - 2003) given by Greg Kroah-Hartman (IBM Corporation) provided a solid understanding on the udev application.

Decibel's UDEV Primer is an in-depth document about udev and Gentoo.

Writing udev rules by fellow Gentoo developer Daniel Drake is an excellent document to learn how to customize your udev installation.
rate this article:
current rating: average rating: 1.3 (33 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back



Support us on Content Nation

New Packages

- as rdf newsfeed
- as rss newsfeed
- as Atom newsfeed
2025-12-30
awscli - 1.44.8
Ebuild name:

app-admin/awscli-1.44.8

Description

Universal Command Line Environment for AWS

Added to portage

2025-12-30

backports-zstd - 1.3.0
Ebuild name:

dev-python/backports-zstd-1.3.0

Description

Backport of PEP-784 adding Zstandard to the standard library

Added to portage

2025-12-30

boto3 - 1.42.18
Ebuild name:

dev-python/boto3-1.42.18

Description

The AWS SDK for Python

Added to portage

2025-12-30

botocore - 1.42.18
Ebuild name:

dev-python/botocore-1.42.18

Description

Low-level, data-driven core of boto 3

Added to portage

2025-12-30

cysignals - 1.12.6
Ebuild name:

dev-python/cysignals-1.12.6

Description

Interrupt and signal handling for Cython

Added to portage

2025-12-30

fakefs - 3.2.0
Ebuild name:

dev-ruby/fakefs-3.2.0

Description

A fake filesystem. Use it in your tests

Added to portage

2025-12-30

faker - 40.1.0
Ebuild name:

dev-python/faker-40.1.0

Description

A Python package that generates fake data for you

Added to portage

2025-12-30

ffi - 1.17.3
Ebuild name:

dev-ruby/ffi-1.17.3

Description

Ruby extension for programmatically loading dynamic libraries

Added to portage

2025-12-30

fiddle - 1.1.8
Ebuild name:

dev-ruby/fiddle-1.1.8

Description

A libffi wrapper for Ruby

Added to portage

2025-12-30

fluidsynth - 2.4.8
Ebuild name:

media-sound/fluidsynth-2.4.8

Description

Software real-time synthesizer based on the Soundfont 2 specifications

Added to portage

2025-12-30

fluidsynth - 2.5.2
Ebuild name:

media-sound/fluidsynth-2.5.2

Description

Software real-time synthesizer based on the Soundfont 2 specifications

Added to portage

2025-12-30

git - 4.0.7
Ebuild name:

dev-ruby/git-4.0.7

Description

Library for using Git in Ruby

Added to portage

2025-12-30

gnupg - 2.4.9
Ebuild name:

app-crypt/gnupg-2.4.9

Description

The GNU Privacy Guard, a GPL OpenPGP implementation

Added to portage

2025-12-30

gnupg - 2.5.16
Ebuild name:

app-crypt/gnupg-2.5.16

Description

The GNU Privacy Guard, a GPL OpenPGP implementation

Added to portage

2025-12-30

guitarix - 0.47.0-r2
Ebuild name:

media-sound/guitarix-0.47.0-r2

Description

Virtual guitar amplifier for Linux

Added to portage

2025-12-30

httparty - 0.24.0
Ebuild name:

dev-ruby/httparty-0.24.0

Description

Makes http fun Also, makes consuming restful web services dead easy

Added to portage

2025-12-30

kombu - 5.6.2
Ebuild name:

dev-python/kombu-5.6.2

Description

AMQP Messaging Framework for Python

Added to portage

2025-12-30

krita - 6.0.0_alpha_pre20251229
Ebuild name:

media-gfx/krita-6.0.0_alpha_pre20251229

Description

Free digital painting application. Digital Painting, Creati

Added to portage

2025-12-30

libcamera - 0.6.0
Ebuild name:

media-libs/libcamera-0.6.0

Description

Complex camera support library

Added to portage

2025-12-30

libmateweather - 1.28.1
Ebuild name:

dev-libs/libmateweather-1.28.1

Description

MATE library to access weather information from online services

Added to portage

2025-12-30

maturin - 1.11.0
Ebuild name:

dev-util/maturin-1.11.0

Description

Build and publish crates with pyo3, rust-cpython and cffi bindings

Added to portage

2025-12-30

minitest-around - 0.6.0
Ebuild name:

dev-ruby/minitest-around-0.6.0

Description

Alternative for setup/teardown dance

Added to portage

2025-12-30

netpbm - 11.13.0
Ebuild name:

media-libs/netpbm-11.13.0

Description

A set of utilities for converting to/from the netpbm (and related) format

Added to portage

2025-12-30

nokogiri - 1.19.0
Ebuild name:

dev-ruby/nokogiri-1.19.0

Description

Nokogiri is an HTML, XML, SAX, and Reader parser

Added to portage

2025-12-30

nomacs - 3.22.0
Ebuild name:

media-gfx/nomacs-3.22.0

Description

Qt-based image viewer

Added to portage

2025-12-30

omemo-dr - 1.2.0
Ebuild name:

dev-python/omemo-dr-1.2.0

Description

OMEMO Crypto Library

Added to portage

2025-12-30

owntone - 29.0
Ebuild name:

media-sound/owntone-29.0

Description

DAAP (iTunes) and MPD media server

Added to portage

2025-12-30

pariemacs - 3.14-r1
Ebuild name:

app-emacs/pariemacs-3.14-r1

Description

sci-mathematics/pari emacs mode

Added to portage

2025-12-30

parsebib - 6.7
Ebuild name:

app-emacs/parsebib-6.7

Description

Emacs Lisp library for reading .bib files

Added to portage

2025-12-30

parseclj - 1.1.1
Ebuild name:

app-emacs/parseclj-1.1.1

Description

Clojure Parser for Emacs Lisp

Added to portage

2025-12-30

parseedn - 1.2.1
Ebuild name:

app-emacs/parseedn-1.2.1

Description

EDN parser for Emacs Lisp

Added to portage

2025-12-30

performous - 1.3.1_p20251224
Ebuild name:

games-arcade/performous-1.3.1_p20251224

Description

SingStar GPL clone

Added to portage

2025-12-30

photoqt - 5.0
Ebuild name:

media-gfx/photoqt-5.0

Description

Simple but powerful Qt-based image viewer

Added to portage

2025-12-30

portage-utils - 0.98
Ebuild name:

app-portage/portage-utils-0.98

Description

Small and fast Portage helper tools written in C

Added to portage

2025-12-30

primecountpy - 0.2.1
Ebuild name:

dev-python/primecountpy-0.2.1

Description

Cython interface to sci-mathematics/primecount

Added to portage

2025-12-30

pstore - 0.2.0
Ebuild name:

dev-ruby/pstore-0.2.0

Description

Transactional File Storage for Ruby Objects

Added to portage

2025-12-30

psutil - 7.2.1
Ebuild name:

dev-python/psutil-7.2.1

Description

Retrieve information on running processes and system utilization

Added to portage

2025-12-30

pygit2 - 1.19.1
Ebuild name:

dev-python/pygit2-1.19.1

Description

Python bindings for libgit2

Added to portage

2025-12-30

pylast - 7.0.1
Ebuild name:

dev-python/pylast-7.0.1

Description

Python interface to last.fm and other api-compatible websites

Added to portage

2025-12-30

qcheck - 0.27
Ebuild name:

dev-ml/qcheck-0.27

Description

QuickCheck inspired property-based testing for OCaml

Added to portage

2025-12-30

readline - 0.0.4
Ebuild name:

dev-ruby/readline-0.0.4

Description

Class to build custom data structures, similar to a Hash

Added to portage

2025-12-30

sabctools - 9.2.1
Ebuild name:

dev-python/sabctools-9.2.1

Description

Module providing raw yEnc encoding/decoding for SABnzbd

Added to portage

2025-12-30

termcolor - 3.3.0
Ebuild name:

dev-python/termcolor-3.3.0

Description

ANSI Color formatting for output in terminal

Added to portage

2025-12-30

tmux - 3.6a
Ebuild name:

app-misc/tmux-3.6a

Description

Terminal multiplexer

Added to portage

2025-12-30

torchvision - 0.24.1
Ebuild name:

sci-ml/torchvision-0.24.1

Description

Datasets, transforms and models to specific to computer vision

Added to portage

2025-12-30

uv - 0.9.20
Ebuild name:

dev-python/uv-0.9.20

Description

A Python package installer and resolver, written in Rust

Added to portage

2025-12-30

uv-build - 0.9.20
Ebuild name:

dev-python/uv-build-0.9.20

Description

PEP517 uv build backend

Added to portage

2025-12-30

xfce4-session - 4.21.1
Ebuild name:

xfce-base/xfce4-session-4.21.1

Description

A session manager for the Xfce desktop environment

Added to portage

2025-12-30

xfce4-settings - 4.20.3
Ebuild name:

xfce-base/xfce4-settings-4.20.3

Description

Configuration system for the Xfce desktop environment

Added to portage

2025-12-30

xpadneo - 0.9.8
Ebuild name:

games-util/xpadneo-0.9.8

Description

Advanced Linux Driver for Xbox One Wireless Controller

Added to portage

2025-12-30

2025-12-29
array-api-compat - 1.13.0
Ebuild name:

dev-python/array-api-compat-1.13.0

Description

Array API standard compatibility wrapper over NumPy and others

Added to portage

2025-12-29

coverage - 7.13.1
Ebuild name:

dev-python/coverage-7.13.1

Description

Code coverage measurement for Python

Added to portage

2025-12-29

darktable - 5.4.0
Ebuild name:

media-gfx/darktable-5.4.0

Description

A virtual lighttable and darkroom for photographers

Added to portage

2025-12-29

elementpath - 5.1.0
Ebuild name:

dev-python/elementpath-5.1.0

Description

XPath 1.0/2.0 parsers and selectors for ElementTree and lxml

Added to portage

2025-12-29

gcc - 15.2.1_p20251227
Ebuild name:

sys-devel/gcc-15.2.1_p20251227

Description

The GNU Compiler Collection

Added to portage

2025-12-29

gcc - 16.0.0_p20251228
Ebuild name:

sys-devel/gcc-16.0.0_p20251228

Description

The GNU Compiler Collection

Added to portage

2025-12-29

git-sources - 6.19_rc3
Ebuild name:

sys-kernel/git-sources-6.19_rc3

Description

The very latest -git version of the Linux kernel

Added to portage

2025-12-29

harfbuzz - 12.3.0
Ebuild name:

media-libs/harfbuzz-12.3.0

Description

An OpenType text shaping engine

Added to portage

2025-12-29

hugin - 2025.0.1
Ebuild name:

media-gfx/hugin-2025.0.1

Description

GUI for the creation & processing of panoramic images

Added to portage

2025-12-29

kshutdown - 6.2
Ebuild name:

kde-misc/kshutdown-6.2

Description

Shutdown manager for desktop environments like KDE Plasma

Added to portage

2025-12-29

lcov - 2.4
Ebuild name:

dev-util/lcov-2.4

Description

A graphical front-end for GCC's coverage testing tool gcov

Added to portage

2025-12-29

libxfce4windowing - 4.20.5
Ebuild name:

xfce-base/libxfce4windowing-4.20.5

Description

Unified widget and session management libs for Xfce

Added to portage

2025-12-29

mediafile - 0.14.0
Ebuild name:

dev-python/mediafile-0.14.0

Description

Read and write audio files' tags in Python

Added to portage

2025-12-29

messagelib - 25.08.3-r2
Ebuild name:

kde-apps/messagelib-25.08.3-r2

Description

Libraries for messaging functions

Added to portage

2025-12-29

moto - 5.1.19
Ebuild name:

dev-python/moto-5.1.19

Description

Mock library for boto

Added to portage

2025-12-29

netavark - 1.17.1
Ebuild name:

app-containers/netavark-1.17.1

Description

A container network stack

Added to portage

2025-12-29

newsboat - 2.42
Ebuild name:

net-news/newsboat-2.42

Description

An RSS/Atom feed reader for text terminals

Added to portage

2025-12-29

openresolv - 3.17.4
Ebuild name:

net-dns/openresolv-3.17.4

Description

A framework for managing DNS information

Added to portage

2025-12-29

parseclj - 1.1.1
Ebuild name:

app-emacs/parseclj-1.1.1

Description

Clojure Parser for Emacs Lisp

Added to portage

2025-12-29

plette - 2.1.0-r1
Ebuild name:

dev-python/plette-2.1.0-r1

Description

Structured Pipfile and Pipfile.lock models

Added to portage

2025-12-29

postfix - 3.11.0_rc2
Ebuild name:

mail-mta/postfix-3.11.0_rc2

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2025-12-29

postfix - 3.12_pre20251226
Ebuild name:

mail-mta/postfix-3.12_pre20251226

Description

A fast and secure drop-in replacement for sendmail

Added to portage

2025-12-29

pwsh - 7.5.4-r2
Ebuild name:

app-shells/pwsh-7.5.4-r2

Description

Cross-platform automation and configuration tool

Added to portage

2025-12-29

pycargoebuild - 0.15.1
Ebuild name:

app-portage/pycargoebuild-0.15.1

Description

A generator for Rust/Cargo ebuilds written in Python

Added to portage

2025-12-29

qmidiarp - 0.7.2
Ebuild name:

media-sound/qmidiarp-0.7.2

Description

Arpeggiator, sequencer and MIDI LFO for ALSA

Added to portage

2025-12-29

sedlex - 3.7
Ebuild name:

dev-ml/sedlex-3.7

Description

Added to portage

2025-12-29

socket-burst-dampener - 1.3.3
Ebuild name:

net-misc/socket-burst-dampener-1.3.3

Description

A daemon that spawns one command per connection, and dampens c

Added to portage

2025-12-29

tldextract - 5.3.1
Ebuild name:

dev-python/tldextract-5.3.1

Description

Accurately separate the TLD from the registered domain and subdomains o

Added to portage

2025-12-29

tlfloat - 1.15.0_p20250711
Ebuild name:

dev-cpp/tlfloat-1.15.0_p20250711

Description

C++ template library for floating point operations

Added to portage

2025-12-29

tumbler - 4.21.1
Ebuild name:

xfce-base/tumbler-4.21.1

Description

A thumbnail service for Thunar

Added to portage

2025-12-29

types-psutil - 7.2.0.20251228
Ebuild name:

dev-python/types-psutil-7.2.0.20251228

Description

Typing stubs for psutil

Added to portage

2025-12-29

vulkan-loader - 1.4.335.0-r1
Ebuild name:

media-libs/vulkan-loader-1.4.335.0-r1

Description

Vulkan Installable Client Driver (ICD) Loader

Added to portage

2025-12-29

xfce4-panel - 4.20.6
Ebuild name:

xfce-base/xfce4-panel-4.20.6

Description

Panel for the Xfce desktop environment

Added to portage

2025-12-29

xfce4-power-manager - 4.21.1
Ebuild name:

xfce-base/xfce4-power-manager-4.21.1

Description

Power manager for the Xfce desktop environment

Added to portage

2025-12-29

xfce4-settings - 4.21.1
Ebuild name:

xfce-base/xfce4-settings-4.21.1

Description

Configuration system for the Xfce desktop environment

Added to portage

2025-12-29

xwaylandvideobridge - 0.4.0_p20250215-r1
Ebuild name:

gui-apps/xwaylandvideobridge-0.4.0_p20250215-r1

Description

Screenshare Wayland windows to XWayland apps

Added to portage

2025-12-29

rdf newsfeed | rss newsfeed | Atom newsfeed
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
- Copyright and legal notices -
Time to create this page: 71.0 ms